package idv.loveloser.dao;

import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A data access object (DAO) providing persistence and search support for
 * MdlWorkshopOld entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see idv.loveloser.dao.MdlWorkshopOld
 * @author MyEclipse Persistence Tools
 */

public class MdlWorkshopOldDAO extends BaseHibernateDAO {
	private static final Logger log = LoggerFactory
			.getLogger(MdlWorkshopOldDAO.class);
	// property constants
	public static final String COURSE = "course";
	public static final String NAME = "name";
	public static final String DESCRIPTION = "description";
	public static final String WTYPE = "wtype";
	public static final String NELEMENTS = "nelements";
	public static final String NATTACHMENTS = "nattachments";
	public static final String PHASE = "phase";
	public static final String FORMAT = "format";
	public static final String GRADINGSTRATEGY = "gradingstrategy";
	public static final String RESUBMIT = "resubmit";
	public static final String AGREEASSESSMENTS = "agreeassessments";
	public static final String HIDEGRADES = "hidegrades";
	public static final String ANONYMOUS = "anonymous";
	public static final String INCLUDESELF = "includeself";
	public static final String MAXBYTES = "maxbytes";
	public static final String SUBMISSIONSTART = "submissionstart";
	public static final String ASSESSMENTSTART = "assessmentstart";
	public static final String SUBMISSIONEND = "submissionend";
	public static final String ASSESSMENTEND = "assessmentend";
	public static final String RELEASEGRADES = "releasegrades";
	public static final String GRADE = "grade";
	public static final String GRADINGGRADE = "gradinggrade";
	public static final String NTASSESSMENTS = "ntassessments";
	public static final String ASSESSMENTCOMPS = "assessmentcomps";
	public static final String NSASSESSMENTS = "nsassessments";
	public static final String OVERALLOCATION = "overallocation";
	public static final String TIMEMODIFIED = "timemodified";
	public static final String TEACHERWEIGHT = "teacherweight";
	public static final String SHOWLEAGUETABLE = "showleaguetable";
	public static final String USEPASSWORD = "usepassword";
	public static final String PASSWORD = "password";
	public static final String NEWPLUGIN = "newplugin";
	public static final String NEWID = "newid";

	public void save(MdlWorkshopOld transientInstance) {
		log.debug("saving MdlWorkshopOld instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(MdlWorkshopOld persistentInstance) {
		log.debug("deleting MdlWorkshopOld instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public MdlWorkshopOld findById(java.lang.Long id) {
		log.debug("getting MdlWorkshopOld instance with id: " + id);
		try {
			MdlWorkshopOld instance = (MdlWorkshopOld) getSession().get(
					"idv.loveloser.dao.MdlWorkshopOld", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(MdlWorkshopOld instance) {
		log.debug("finding MdlWorkshopOld instance by example");
		try {
			List results = getSession()
					.createCriteria("idv.loveloser.dao.MdlWorkshopOld")
					.add(Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding MdlWorkshopOld instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from MdlWorkshopOld as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByCourse(Object course) {
		return findByProperty(COURSE, course);
	}

	public List findByName(Object name) {
		return findByProperty(NAME, name);
	}

	public List findByDescription(Object description) {
		return findByProperty(DESCRIPTION, description);
	}

	public List findByWtype(Object wtype) {
		return findByProperty(WTYPE, wtype);
	}

	public List findByNelements(Object nelements) {
		return findByProperty(NELEMENTS, nelements);
	}

	public List findByNattachments(Object nattachments) {
		return findByProperty(NATTACHMENTS, nattachments);
	}

	public List findByPhase(Object phase) {
		return findByProperty(PHASE, phase);
	}

	public List findByFormat(Object format) {
		return findByProperty(FORMAT, format);
	}

	public List findByGradingstrategy(Object gradingstrategy) {
		return findByProperty(GRADINGSTRATEGY, gradingstrategy);
	}

	public List findByResubmit(Object resubmit) {
		return findByProperty(RESUBMIT, resubmit);
	}

	public List findByAgreeassessments(Object agreeassessments) {
		return findByProperty(AGREEASSESSMENTS, agreeassessments);
	}

	public List findByHidegrades(Object hidegrades) {
		return findByProperty(HIDEGRADES, hidegrades);
	}

	public List findByAnonymous(Object anonymous) {
		return findByProperty(ANONYMOUS, anonymous);
	}

	public List findByIncludeself(Object includeself) {
		return findByProperty(INCLUDESELF, includeself);
	}

	public List findByMaxbytes(Object maxbytes) {
		return findByProperty(MAXBYTES, maxbytes);
	}

	public List findBySubmissionstart(Object submissionstart) {
		return findByProperty(SUBMISSIONSTART, submissionstart);
	}

	public List findByAssessmentstart(Object assessmentstart) {
		return findByProperty(ASSESSMENTSTART, assessmentstart);
	}

	public List findBySubmissionend(Object submissionend) {
		return findByProperty(SUBMISSIONEND, submissionend);
	}

	public List findByAssessmentend(Object assessmentend) {
		return findByProperty(ASSESSMENTEND, assessmentend);
	}

	public List findByReleasegrades(Object releasegrades) {
		return findByProperty(RELEASEGRADES, releasegrades);
	}

	public List findByGrade(Object grade) {
		return findByProperty(GRADE, grade);
	}

	public List findByGradinggrade(Object gradinggrade) {
		return findByProperty(GRADINGGRADE, gradinggrade);
	}

	public List findByNtassessments(Object ntassessments) {
		return findByProperty(NTASSESSMENTS, ntassessments);
	}

	public List findByAssessmentcomps(Object assessmentcomps) {
		return findByProperty(ASSESSMENTCOMPS, assessmentcomps);
	}

	public List findByNsassessments(Object nsassessments) {
		return findByProperty(NSASSESSMENTS, nsassessments);
	}

	public List findByOverallocation(Object overallocation) {
		return findByProperty(OVERALLOCATION, overallocation);
	}

	public List findByTimemodified(Object timemodified) {
		return findByProperty(TIMEMODIFIED, timemodified);
	}

	public List findByTeacherweight(Object teacherweight) {
		return findByProperty(TEACHERWEIGHT, teacherweight);
	}

	public List findByShowleaguetable(Object showleaguetable) {
		return findByProperty(SHOWLEAGUETABLE, showleaguetable);
	}

	public List findByUsepassword(Object usepassword) {
		return findByProperty(USEPASSWORD, usepassword);
	}

	public List findByPassword(Object password) {
		return findByProperty(PASSWORD, password);
	}

	public List findByNewplugin(Object newplugin) {
		return findByProperty(NEWPLUGIN, newplugin);
	}

	public List findByNewid(Object newid) {
		return findByProperty(NEWID, newid);
	}

	public List findAll() {
		log.debug("finding all MdlWorkshopOld instances");
		try {
			String queryString = "from MdlWorkshopOld";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public MdlWorkshopOld merge(MdlWorkshopOld detachedInstance) {
		log.debug("merging MdlWorkshopOld instance");
		try {
			MdlWorkshopOld result = (MdlWorkshopOld) getSession().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(MdlWorkshopOld instance) {
		log.debug("attaching dirty MdlWorkshopOld instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(MdlWorkshopOld instance) {
		log.debug("attaching clean MdlWorkshopOld instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}